(in-package :lilu-clim)

(defmacro with-apropos-fn (&body body)
  `(let ((lilu-mcclim-apropos:*apropos-edit-fn*
           #'(lambda (file pos nline)
               (declare (ignore pos))
               (lilu-app:edit file :nline nline :wait-p nil)))
         (lilu-mcclim-apropos:*apropos-inspect-fn*
           #'(lambda (object)
               (lilu-app:inspect-object object :wait-p nil))))
     ,@body))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :package-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-package-apropos :new-process nil))))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :system-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-system-apropos :new-process nil))))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :command-table-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-command-table-apropos :new-process nil))))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :symbol-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-symbol-apropos :new-process nil))))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :class-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-class-apropos :new-process nil))))

(setf (lilu-app::application-entry-fn
       (lilu-app:find-app :command-apropos))
      #'(lambda (app &rest args)
          (declare (ignore app args))
          (with-apropos-fn
              (lilu-mcclim-apropos:run-command-apropos :new-process nil))))
